function shaizi(num) {
  let number = 0;
  if (num == undefined) {
    number = getNumber();
  } else {
    do {
      number += getNumber();
      num--;
    } while (num != 0);
  }
  return number;
}

function getNumber() {
  return Math.floor(Math.random()*6 + 1);
}

let str1 = shaizi();
let str2 = shaizi(2);

console.log("一次骰子:",str1);
console.log("两次骰子:",str2);
